package com.fqgame.user.mq;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * 订单消息监听器
 */
@Slf4j
@Component
public class OrderMessageListener {

    /**
     * 处理订单创建消息
     */
    @RabbitListener(queues = "order.notify.queue")
    public void handleOrderCreatedMessage(Map<String, Object> message) {
        log.info("收到订单创建消息：{}", message);
        
        try {
            String orderNo = (String) message.get("orderNo");
            Long userId = Long.valueOf(message.get("userId").toString());
            
            // 处理订单通知逻辑
            log.info("处理订单通知，订单号：{}，用户ID：{}", orderNo, userId);
            
            // 实际业务逻辑...
            
        } catch (Exception e) {
            log.error("处理订单创建消息失败", e);
            // 实际应用中可能需要重试机制或死信队列
            throw e;
        }
    }
}